cmake_minimum_required(VERSION 3.8)
project(bot_control)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# 添加包资源安装
install(
  DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)


find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED) 
find_package(visualization_msgs REQUIRED)

# 传感器读取节点
add_executable(sensor_reader src/sensor_reader.cpp)
ament_target_dependencies(sensor_reader
  rclcpp
  sensor_msgs
  nav_msgs
  std_msgs
)

# 键盘控制节点
add_executable(keyboard_control src/keyboard_control.cpp)
ament_target_dependencies(keyboard_control
  rclcpp
  geometry_msgs
)

# Gazebo 目标选择节点
add_executable(gazebo_target_selector src/gazebo_target_selector.cpp)
ament_target_dependencies(gazebo_target_selector
  rclcpp
  geometry_msgs
  gazebo_msgs
  tf2_ros
  tf2_geometry_msgs
  nav_msgs
)

# path_publisher.cpp
add_executable(path_publisher src/path_publisher.cpp)
ament_target_dependencies(path_publisher
  rclcpp
  geometry_msgs
  nav_msgs
  tf2_ros
  visualization_msgs
)

# path_follower.cpp 路径跟随
add_executable(path_follower src/path_follower.cpp)
ament_target_dependencies(path_follower
  rclcpp
  geometry_msgs
  nav_msgs
  tf2_ros
  sensor_msgs
)

# 安装目标
install(TARGETS
  sensor_reader
  keyboard_control
  # gazebo_target_selector
  path_publisher
  path_follower
  DESTINATION lib/${PROJECT_NAME}
)

# 安装包资源
install(
  DIRECTORY 
    launch
  DESTINATION share/${PROJECT_NAME}
)

# 安装 package.xml
install(
  FILES package.xml
  DESTINATION share/${PROJECT_NAME}
)

ament_package()